﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PhysioAssist2Win
{
    /// <summary>
    /// Interaction logic for Profissionais.xaml
    /// </summary>
    public partial class Profissionais : Window
    {
        public Profissionais()
        {
            InitializeComponent();



            //Ajusta posição e tamanho das janelas
            double width = System.Windows.SystemParameters.PrimaryScreenWidth;
            double height = System.Windows.SystemParameters.PrimaryScreenHeight;

            winProfissionais.Width = width;
            winProfissionais.Height = height;

            winProfissionais.Left = 0;
            winProfissionais.Top = 0;



            //Larguras dos Paineis
            pnlEsq.Width = winProfissionais.Width * 0.2;
            pnlEsq.Height = winProfissionais.Height;
            pnlEsq.Margin = new Thickness(20, 20, 0, 0);

            pnlDir.Width = winProfissionais.Width * 0.8;
            pnlDir.Height = winProfissionais.Height;
            pnlDir.Margin = new Thickness(20, 20, 0, 0);


            //Paineis dos Pacientes
            pnlPro1.Width = (pnlDir.Width - 140) * 0.2;
            pnlPro1.Height = pnlDir.Height;

            pnlPro2.Width = pnlPro1.Width;
            pnlPro2.Height = pnlPro1.Height;

            pnlPro3.Width = pnlPro1.Width;
            pnlPro3.Height = pnlPro1.Height;

            pnlPro4.Width = pnlPro1.Width;
            pnlPro4.Height = pnlPro1.Height;

            pnlPro5.Width = pnlPro1.Width;
            pnlPro5.Height = pnlPro1.Height;



            //Carrega Profissionais
            CarregaProfissionais();



        }



        private void CarregaProfissionais()
        {

            WS.WSSoapClient client = new WS.WSSoapClient();
            WS.Profissional[] lst = client.ListaProfissionais();

            int i = 0;

            foreach (WS.Profissional pro in lst)
            {

                i++;

                //Foto do paciente
                Image img = new Image();
                Uri src = new Uri(pro.foto, UriKind.Absolute);
                BitmapImage bitimg = new BitmapImage(src);
                img.Source = bitimg;
                img.Height = 150;
                img.Stretch = Stretch.Fill;
                img.StretchDirection = StretchDirection.Both;
                img.Width = pnlPro1.Width;


                //Nome do paciente
                Label lbl = new Label();
                lbl.FontSize = 15;
                lbl.Content = pro.nome;


                //Insere no form
                if (i % 5 == 1)
                {
                    pnlPro1.Children.Add(img);
                    pnlPro1.Children.Add(lbl);
                }
                if (i % 5 == 2)
                {
                    pnlPro2.Children.Add(img);
                    pnlPro2.Children.Add(lbl);
                }
                if (i % 5 == 3)
                {
                    pnlPro3.Children.Add(img);
                    pnlPro3.Children.Add(lbl);
                }
                if (i % 5 == 4)
                {
                    pnlPro4.Children.Add(img);
                    pnlPro4.Children.Add(lbl);
                }
                if (i % 5 == 0)
                {
                    pnlPro5.Children.Add(img);
                    pnlPro5.Children.Add(lbl);
                }


            }

        }







        private void pnlEsq_MouseDown(object sender, MouseButtonEventArgs e)
        {
            winProfissionais.Close();
        }


    }
}
